/*    */ package com.zimbra.cs.service.admin;
/*    */ 
/*    */ import com.zimbra.common.account.Key.AccountBy;
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.common.soap.AdminConstants;
/*    */ import com.zimbra.common.soap.Element;
/*    */ import com.zimbra.common.util.AccountLogger;
/*    */ import com.zimbra.common.util.Log;
/*    */ import com.zimbra.common.util.Log.Level;
/*    */ import com.zimbra.common.util.LogFactory;
/*    */ import com.zimbra.common.util.ZimbraLog;
/*    */ import com.zimbra.cs.account.Account;
/*    */ import com.zimbra.cs.account.Provisioning;
/*    */ import com.zimbra.cs.account.Server;
/*    */ import com.zimbra.cs.account.accesscontrol.AdminRight;
/*    */ import com.zimbra.cs.account.accesscontrol.Rights.Admin;
/*    */ import com.zimbra.soap.ZimbraSoapContext;
/*    */ import java.util.HashMap;
/*    */ import java.util.List;
/*    */ import java.util.Map;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class GetAllAccountLoggers
/*    */   extends AdminDocumentHandler
/*    */ {
/*    */   public Element handle(Element request, Map<String, Object> context)
/*    */     throws ServiceException
/*    */   {
/* 41 */     ZimbraSoapContext zsc = getZimbraSoapContext(context);
/*    */     
/* 43 */     Server localServer = Provisioning.getInstance().getLocalServer();
/* 44 */     checkRight(zsc, context, localServer, Rights.Admin.R_manageAccountLogger);
/*    */     
/* 46 */     Provisioning prov = Provisioning.getInstance();
/* 47 */     Map<String, Element> accountElements = new HashMap();
/*    */     
/* 49 */     Element response = zsc.createElement(AdminConstants.GET_ALL_ACCOUNT_LOGGERS_RESPONSE);
/* 50 */     for (AccountLogger al : LogFactory.getAllAccountLoggers())
/*    */     {
/* 52 */       Account account = prov.get(Key.AccountBy.name, al.getAccountName(), zsc.getAuthToken());
/* 53 */       if (account == null) {
/* 54 */         ZimbraLog.misc.info("GetAllAccountLoggers: unable to find account '%s'.  Ignoring account logger.", new Object[] { al.getAccountName() });
/*    */ 
/*    */       }
/*    */       else
/*    */       {
/*    */ 
/* 60 */         Element eAccountLogger = (Element)accountElements.get(account.getId());
/* 61 */         if (eAccountLogger == null) {
/* 62 */           eAccountLogger = response.addElement("accountLogger");
/* 63 */           accountElements.put(account.getId(), eAccountLogger);
/*    */         }
/* 65 */         eAccountLogger.addAttribute("id", account.getId());
/* 66 */         eAccountLogger.addAttribute("name", account.getName());
/*    */         
/* 68 */         Element eLogger = eAccountLogger.addElement("logger");
/* 69 */         eLogger.addAttribute("category", al.getCategory());
/* 70 */         eLogger.addAttribute("level", al.getLevel().toString());
/*    */       }
/*    */     }
/* 73 */     return response;
/*    */   }
/*    */   
/*    */   public void docRights(List<AdminRight> relatedRights, List<String> notes)
/*    */   {
/* 78 */     relatedRights.add(Rights.Admin.R_manageAccountLogger);
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/service/admin/GetAllAccountLoggers.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */